mounted() {
                window.onbeforeunload = function(e) {
                    <?php
                    $servername = "localhost";
                    $username = "root";
                    $password = "wgz52157";
                    $dbname = "myFirstDB";
                    // 创建连接
                    $conn = new mysqli($servername, $username, $password, $dbname);
                    mysqli_query($conn, "DELETE FROM MyUsers  WHERE id='$sessionid'");
                    ?>;
                    window.location.reload();
                }
            },

                <!-- 关闭页面删除用户数据 -->

    <script>
        window.onbeforeunload = function(e) {
            <?php
            $servername = "localhost";
            $username = "root";
            $password = "wgz52157";
            $dbname = "myFirstDB";
            // 创建连接
            $conn = new mysqli($servername, $username, $password, $dbname);
            mysqli_query($conn, "DELETE FROM MyUsers  WHERE id='$sessionid'");
            mysqli_close($conn);
            ?>;
            window.location.reload();
        }
    </script>


$exist = 0;
// 判断该用户是否已经存在数据库中
$result = mysqli_query($conn, "SELECT * FROM MyUsers WHERE id='$sessionid'");
while ($existjudge = mysqli_fetch_array($result)) {
    if ($existjudge['id'] == $sessionid) {
        $exist = 1;
        break;
    }
}
// $rowjudge = mysqli_fetch_array($judge);
if ($exist == 0) { //如果该用户不在数据库，则按规则添加相应信息
    //定义插入的组数初始为1

    $insertgroupnum = 1;

    //定义插入数据库的用户名，在分组的时候补全具体是用户号数

    $user_name = "用户1";
    $number = '1';

    //对数据库中存在的组数进行计数

    $nowgroupnum = mysqli_query($conn, "SELECT groupnum,count(*)AS COUNT FROM MyUsers GROUP BY groupnum ORDER BY groupnum ASC");

    // $row = mysqli_fetch_array($nowgroupnum);
    // if(empty($row['COUNT'])){
    //     $user_name.=$number;
    // }
    while ($row = mysqli_fetch_array($nowgroupnum)) {
        // echo $row['groupnum'] . " " . $row['COUNT'];
        // echo "<br>";
        if ($row['COUNT'] < $maxgroupper) {
            $insertgroupnum = $row['groupnum'];
            $user_name = substr($user_name, 0, strlen($user_name) - 1);
            $number = $row['COUNT'] + 1;
            $user_name .= $number;
            break;
        } elseif ($row['COUNT'] == $maxgroupper) {
            $insertgroupnum = $row['groupnum'] + 1;
            continue;
        } elseif ($row['COUNT'] > $maxgroupper) {
            $insertgroupnum = $row['groupnum'] + 1;
            continue;
        }
    }


    //总收益为10减去本次选择的值

    $allincomenow = 10 - $_POST["num"];

    $sql = "INSERT INTO MyUsers (id,usernamenum, groupnum, allincome,choosenum,roundnum)
   VALUES ('{$sessionid}','{$user_name}', '{$insertgroupnum}', '{$allincomenow}','{$_POST["num"]}','{$round}')";
    if (mysqli_query($conn, $sql)) {
        // echo "新记录插入成功"."<br>";
    } else {
        echo "Error: " . $sql . "<br>" . mysqli_error($conn);
    }



    //数据反馈，告诉用户本轮每一个人所选择的值以及本轮收益
    //要先判断本组所有用户是否都已经选择好值！！

    //定义一个计算本轮分给每一个用户的值的收益变量cal
    $cal = 0;
    $sleep_time = 1;
    while (true) {
        $resultback = mysqli_query($conn, "SELECT * FROM MyUsers WHERE roundnum='$round' AND groupnum=$insertgroupnum ORDER BY usernamenum ASC");

        //判断当前到达本轮的用户有几个

        //创建变量计数到达本轮的用户数量
        $countbacknum = mysqli_num_rows($resultback);
        //开始对每一个用户的选择值进行判断及计算
        if ($countbacknum == $maxgroupper) {
            echo "第" . $round . "轮" . "<br>";
            while ($rowback = $resultback->fetch_assoc()) {
                echo $rowback["usernamenum"] . ":" . $rowback["choosenum"] . "<br>";
                $cal = $cal + $rowback["choosenum"];
            }
            $cal = ($cal * 1.5) / $maxgroupper;
            echo "收益:" . $cal;
            break;
        } else {
            sleep($sleep_time);
            continue;
        }
    }

    //得到收益后对数据库进行修改，将收益加入到allincome中
    mysqli_query($conn, "UPDATE MyUsers SET allincome=allincome+'$cal' WHERE id='$sessionid'");
    $getallincome = mysqli_query($conn, "SELECT *FROM MyUsers WHERE id='$sessionid'");
    $incomeout = 0;
    while ($group = mysqli_fetch_array($getallincome)) {
        $incomeout = $group['allincome'];
        break;
    }
}